<extend name="Public/base"/>
<block name="style">
<style type="text/css">	
	.div-tc{
		"display":"block";
		"z-index":"999";
		"position":"absolute";
		"left":"100px";
		"top":m.top;
	}
</style>
</block>
<block name="body">
	<div class="main-title">
		<h2>订单管理</h2>
	</div>
	<div class="tools auth-botton">
		<button class="btn ajax-post confirm" url="{:U('changeStatus?method=confirmorder')}" target-form="ids">接 单</button>
        <button class="btn ajax-post confirm" url="{:U('changeStatus?method=cancelorder')}" target-form="ids">取 消</button>
	</div>
		<!-- 数据列表 -->
    <div class="data-table table-striped">
	    <table class="">
	    	<thead>
	    		<tr>
	    			<th class="row_selected row-selected"><input type="checkbox" class="check-all"></th>
	    			<th>ID</th>
	    			<th>日期</th>
	    			<th>订单号</th>
	    			<th>客户名称</th>
	    			<th>合计</th>
	    			<th>下单时间</th>
	    			<th>状态</th>
	    			<th>操作</th>
	    		</tr>
	    	</thead>
	    	<tbody>
	    		<notempty name="_list">
	    		<volist name="_list" id="vo">
	    		<tr>
	    			<td><input type="checkbox" class="ids" name="id[]" value="{$vo.id}"></td>
	    			<td>{$vo.id}</td>
	    			<td>{$vo.orderdate|time_format=###,"Y-m-d"}</td>
	    			<td>{$vo.ordernum}</td>
	    			<td>{$vo.customers_name}</td>
	    			<td>{$vo.total}</td>
	    			<td>{$vo.create_time|time_format=###,"Y-m-d H:m:s"}</td>
	    			<td>{$vo.status_text}</td>
	    			<td>
					<a href="{:U('Order/orderdetail?id='.$vo['id'])}">明细</a>
					<a href="{:U('Order/changeStatus?method=confirmorder&id='.$vo['id'])}" class="confirm ajax-get">接单</a>
	    			<a href="{:U('Order/changeStatus?method=cancelorder&id='.$vo['id'])}" class="confirm ajax-get">取消</a></td>
	    		</tr>
	    		</volist>
	    		<else/>
	    		<td colspan="10" class="text-center">暂时还没有数据！</td>
	    		</notempty>
	    	</tbody>
	    </table>
	    <div class="page">
	    	{$_page}
	    </div>
    </div>
    
</block>
<block name="script">
	<script type="text/javascript">
	$(function(){
		$("#receiptbtn").click(function(){
			var x;

			var person=prompt("请输入收据号","");
			if (person!=null && person!="")
			{
			    $.post("{:U('Order/setReceiptnum')}",{},function(data){
			    	refresh();
			    })
			}
		});

		$(".ajax-post-receipt").click(function(){
			var receipt=prompt("请输入收据号","");
			if (receipt!=null && receipt!="")
			{
				var target,query,form;
		        var target_form = $(this).attr('target-form');
		        var that = this;
		        var nead_confirm=false;
		        target = $(this).attr('url');
		        form = $('.'+target_form);
		        query = form.serialize();
		        query = query +'&receiptnum='+receipt;
		        $.post(target,query).success(function(data){
		        	if (data.status==1) {
		        		refresh();
		        	}else{
		        		updateAlert(data.info);
	                    setTimeout(function(){
	                    	$(that).removeClass('disabled').prop('disabled',false);
	                        if (data.url) {
	                            location.href=data.url;
	                        }else{
	                            $('#top-alert').find('button').click();
	                        }
	                    },1500);
		        	}
			    });
			    return false;
			}
			else{
				updateAlert("请输入收据号！");
                setTimeout(function(){
                	$("#top-alert").removeClass("block");
                },1500);
			}
		});
	});

	function refresh(){
	    window.location.reload();//刷新当前页面.
	    
	    //或者下方刷新方法
	    //parent.location.reload()刷新父亲对象（用于框架）--需在iframe框架内使用
	    // opener.location.reload()刷新父窗口对象（用于单开窗口
	  //top.location.reload()刷新最顶端对象（用于多开窗口）
	}
    //导航高亮
    highlight_subnav('{:U('Order/confirm')}');
	</script>
</block>